import java.awt.Component;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
public class Test {
    
    public Test() {
    }
    
    private static Icon i = new ImageIcon("database_online.png");
    private static Object[] data = {
        new ImageListElement(i, "aaaaa"),
        new ImageListElement(i, "bbbbb")
    };
    public static void main(String[] args) {
        
        JFrame f = new JFrame();
        JList list = new JList(data);
        list.setCellRenderer(new ImageListCellsRedender());
        f.getContentPane().add(list);
        f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
        f.setVisible(true);
    }
    
}


@SuppressWarnings("serial")
class ImageListCellsRedender extends javax.swing.DefaultListCellRenderer {
    
    /** Creates a new instance of ImageListCellsRedender */
    public ImageListCellsRedender() {
    }
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        if (value instanceof ImageListElement) {
            ImageListElement elem = (ImageListElement) value;
            Icon i = elem.icon;
            String s = elem.text;
            JLabel l = (JLabel) super.getListCellRendererComponent(list, s, index, isSelected, cellHasFocus);
            l.setIcon(i);
            return l;
        }
        
       return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    }
    
}



class ImageListElement {
    
    /** Creates a new instance of ImageListElement */
    public ImageListElement(Icon i, String s) {
        icon  = i;
        text = s;
    }
    public Icon icon;
    public String text;
}